package br.com.util.filter;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;

import br.com.vdn.vo.UsuarioVo;


public class doFilter implements Filter
{
	
	public doFilter()
	{
	}

	public void destroy()
	{
		
	}

	public void doFilter(ServletRequest request, ServletResponse response,
			FilterChain chain) throws IOException, ServletException
	{
		HttpServletRequest request2 = (HttpServletRequest) request;
		UsuarioVo vo = (UsuarioVo) request2.getSession().getAttribute("usuarioLogado");
		if (vo == null)
		{
			request.getRequestDispatcher("/pages/login.jsf").forward(request, response);   
		}
		else
		{
			chain.doFilter(request, response);
		}
	}

	public void init(FilterConfig arg0) throws ServletException
	{
		
	}

}

